<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>方案页面</title>
    <link rel="stylesheet" href="../../res/layui/css/layui.css" media="all">
    <script src="../../res/js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="../../res/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../res/js/Tools.js"></script>
    <script type="text/javascript"  src="../../res/js/login_common.js"></script>
</head>
<body>

<table class="layui-hide" id="test" lay-filter="test"></table>
<script type="text/javascript" charset="utf-8">
    var laydate =null;
    var table2=null;
    layui.use(['table','layedit', 'laydate'], function(){
        var table = layui.table
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;
        table2=table.render({
            elem: '#test'
            ,url:'../../AtsSchemeFsController/selectAll'
            ,toolbar: '#toolbarDemo'
            ,page: true //开启分页
            ,title: '方案表'
            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field:'schemeName', title:'方案名称', width: 100, align:'center', fixed: 'left'}
                ,{field:'year', title:'方案年度', width: 100, align:'center'}
                ,{field:'month', title:'方案月份', width: 100, align:'center'}
                ,{field:'schemeType', title:'方案类型', width: 150, align:'center'}
                ,{field:'coachName', title:'教练姓名', width: 100, align:'center'}
                ,{field:'resultTime', title:'反馈时间', width: 100, align:'center'}
                ,{field:'resultExp', title:'实施情况', width: 100, align:'center'}
                ,{field:'resultEffect', title:'实施效果', width: 100, align:'center'}
                ,{fixed:'right', title:'操作', width:400, align:'center',toolbar: '#barDemo'}
            ]]

        });

        /* 头部工具栏监听 */
        table.on('toolbar(test)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id)
                ,data = checkStatus.data; //获取选中的数据
            switch(obj.event){
                case 'add':
                    var schemeName=$("#schemeName").val();
                    var year=$("#year").val();
                    var month=$("#month").val();
                    //iframe层
                    layer.open({
                        type: 2,
                        title: '新增页面',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['65%', '80%'],
                        content: 'AtsSchemeAddorUpdate.html', //iframe的url
                        end:function(){
                            $("#schemeName").val(schemeName);
                            $("#year").val(year);
                            $("#month").val(month);
                        }
                    });
                    
                    break;
                case  'findByKey':
                    var schemeName=$("#schemeName").val();
                    var year=$("#year").val();
                    var month=$("#month").val();
                    table2.reload({
                        where: {
                            schemeName: $("#schemeName").val(),
                            year: $("#year").val(),
                            month: $("#month").val(),
                        },
                        page: {
                            curr: 1
                        }
                    });
                    
                    //显示搜索的关键字
                    $("#schemeName").val(schemeName);
                    $("#year").val(year);
                    $("#month").val(month);
                    break;
                case 'daochu':
                    var data = checkStatus.data;
                    $.each(data, function(index, item) {
                        setTimeout(function(){
                            var url="../../ExportWord/expertWord?schemeId="+item.schemeId;
                            window.open(url);
                        },1000)
                    });

                    break;

                case 'delMany':
                    var data = checkStatus.data;
                    var ids = "";
                    for (var i = 0; i < data.length; i++) {
                        ids += data[i].schemeId + ",";
                    }
                    ids = ids.slice(0, -1);
                    console.info(ids);
                    if(ids==null||ids==""){
                        layer.msg("请至少选择一行！");
                        return;
                    }else{
                        var url = "../../AtsSchemeFsController/deleteMany";
                        var datas = {schemeIds: ids};
                        $.post(url, datas, function (objs) {
                            if(objs.num==1){
                                layer.msg(objs.msg, {
                                    icon: 6,
                                    time: 500
                                }, function () {
                                    window.location.reload();
                                });
                            }else{
                                layer.msg(objs.msg, {
                                    icon: 2,
                                    time: 500
                                }, function () {
                                    return;
                                });
                            }
                        }, "json");
                    }

            };
        });

        table.on('tool(test)', function(obj){
            var schemeName=$("#schemeName").val();
            var year=$("#year").val();
            var month=$("#month").val();
            var data = obj.data;
            if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                    var url="../../AtsSchemeFsController/deleteByPrimaryKey";
                    var dataone={"schemeId":data.schemeId};
                    $.post(url,dataone,function(obj){
                        //提示
                        layer.msg(obj.msg);
                    },"json")
                    
                    $("#schemeName").val(schemeName);
                    $("#year").val(year);
                    $("#month").val(month);
                });
            } else if(obj.event === 'look'){
                var schemeName=$("#schemeName").val();
                var year=$("#year").val();
                var month=$("#month").val();
                var data1 = obj.data;//获取当前行
                //iframe层
                layer.open({
                    type: 2,
                    title: '查看页面',
                    shadeClose: true,
                    shade: 0.3,
                    area: ['80%', '75%'],
                    content: 'LookAtsScheme.html?id='+data.schemeId, //iframe的url
                    end:function(){
                        $("#schemeName").val(schemeName);
                        $("#year").val(year);
                        $("#month").val(month);
                        
                    }
                });
            }else if(obj.event === 'edit'){
                var schemeName=$("#schemeName").val();
                var year=$("#year").val();
                var month=$("#month").val();
                var data1 = obj.data;//获取当前行
                //iframe层
                layer.open({
                    type: 2,
                    title: '修改页面',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['60%', '56%'],
                    content: 'AtsSchemeAddorUpdate.html?id='+data.schemeId, //iframe的url
                    end:function(){
                        $("#schemeName").val(schemeName);
                        $("#year").val(year);
                        $("#month").val(month);
                    }
                });
            }else if(obj.event === 'feedback'){
                var schemeName=$("#schemeName").val();
                var year=$("#year").val();
                var month=$("#month").val();
                var data1 = obj.data;//获取当前行
                //iframe层
                layer.open({
                    type: 2,
                    title: '反馈页面',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['60%', '56%'],
                    content: 'Feedback.html?id='+data.schemeId, //iframe的url
                    end:function(){
                        $("#schemeName").val(schemeName);
                        $("#year").val(year);
                        $("#month").val(month);
                    }
                });
            }else if(obj.event === 'application'){
                var schemeName=$("#schemeName").val();
                var year=$("#year").val();
                var month=$("#month").val();
                var data = obj.data;//获取当前行
                //iframe层
                layer.open({
                    type: 2,
                    title: '申请页面',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['58%', '40%'],
                    content: 'Application.html?id='+data.schemeId , //iframe的url
                    end:function(){
                        $("#schemeName").val(schemeName);
                        $("#year").val(year);
                        $("#month").val(month);
                    }
                });
            }else if(obj.event === 'check'){
                var schemeName=$("#schemeName").val();
                var year=$("#year").val();
                var month=$("#month").val();
                var data1 = obj.data;//获取当前行
                //iframe层
                layer.open({
                    type: 2,
                    title: '审核页面',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['60%', '56%'],
                    content: 'Check.html?id='+data.schemeId , //iframe的url
                    end:function(){
                        $("#schemeName").val(schemeName);
                        $("#year").val(year);
                        $("#month").val(month);
                    }
                });
            }else if(obj.event==='reply'){
                var schemeName=$("#schemeName").val();
                var year=$("#year").val();
                var month=$("#month").val();
                var data1 = obj.data;//获取当前行
                //iframe层
                layer.open({
                    type: 2,
                    title: '回复页面',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['60%', '56%'],
                    content: 'Reply.html?id='+data.schemeId +'&name='+data.schemeName, //iframe的url
                    end:function(){
                        $("#schemeName").val(schemeName);
                        $("#year").val(year);
                        $("#month").val(month);
                    }
                });
            }


        });
        
    });

</script>
<script type="text/html" id="toolbarDemo">
    <div class="layui-inline">
        <input class="layui-input" id="schemeName" name="schemeName"  autocomplete="off" placeholder="请输入方案名称">
    </div>
    <div class="layui-input-inline">
        <input class="layui-input" id="year" name="year"  autocomplete="off" placeholder="请输入年份" >
    </div>
    <div class="layui-input-inline">
        <input class="layui-input" id="month" name="month"  autocomplete="off" placeholder="请输入月份" >
    </div>
    <button class="layui-btn" data-type="reload" lay-event="findByKey" id="findByKey">搜索</button>

    {{# if(hasPrivilege("COACHYY")){ }}
    {{# if(loginObj.manager.companyId == 2 || loginObj.manager.standbyThree == "superman"){ }}
    <a class="layui-btn"  data-type="reload" lay-event="add">新增</a>
    {{# } }}
    {{# } }}
    <a class="layui-btn layui-btn-warm" id="daochu" lay-event="daochu"  data-type="reload">批量导出</a>
    {{# if(hasPrivilege("COACHYY")){ }}
    {{# if(loginObj.manager.companyId == 2 || loginObj.manager.standbyThree == "superman"){ }}
    <a class="layui-btn layui-btn-danger" id="delMany" lay-event="delMany"  data-type="reload">批量删除</a>
    {{# } }}
    {{# } }}
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs"  lay-event="look">查看</a>

    {{# if(hasPrivilege("COACHYY")){ }}
    {{# if(loginObj.manager.clerkId == d.coachId || loginObj.manager.standbyThree == "superman"){ }}
    <a class="layui-btn layui-btn-xs"  lay-event="edit">修改</a>
    {{# } else{}}
    <button class="layui-btn layui-btn-xs layui-btn-disabled"  lay-event="edit" disabled="disabled">修改</button>
    {{# } }}
    {{# } }}

    {{# if(hasPrivilege("COACHYY")){ }}
    {{# if(loginObj.manager.clerkId == d.coachId || loginObj.manager.standbyThree == "superman"){ }}
    {{# if(d.remark=="10" || d.remark=="20"){ }}
    <button class="layui-btn layui-btn-xs layui-btn-warm layui-btn-disabled"  lay-event="feedback" disabled="disabled">反馈</button>
    {{# } else{}}
    <a class="layui-btn layui-btn-xs layui-btn-warm"  lay-event="feedback">反馈</a>
    {{# } }}
    {{# } else{}}
    <button class="layui-btn layui-btn-xs layui-btn-warm layui-btn-disabled"  lay-event="feedback" disabled="disabled">反馈</button>
    {{# } }}
    {{# } }}

    {{# if(hasPrivilege("COACHYY")){ }}
    {{# if(loginObj.manager.clerkId == d.coachId || loginObj.manager.standbyThree == "superman"){ }}
    {{# if(d.remark=="20" || d.remark=="40"){ }}
    <button class="layui-btn layui-btn-xs layui-btn-normal layui-btn-disabled"  lay-event="application" disabled="disabled">申请</button>
    {{# } else{}}
    <a class="layui-btn layui-btn-xs layui-btn-normal"  lay-event="application">申请</a>
    {{# } }}
    {{# } else{}}
    <button class="layui-btn layui-btn-xs layui-btn-normal layui-btn-disabled"  lay-event="application" disabled="disabled">申请</button>
    {{# } }}
    {{# } }}



    {{# if(hasPrivilege("CHECKYY")){ }}
    {{# if(d.remark=="10" &&(loginObj.manager.standbyThree == "superman" || loginObj.manager.companyId == 1)){ }}
    <a class="layui-btn layui-btn-danger layui-btn-xs"  lay-event="check">审核</a>
    {{# } else{}}
    <button class="layui-btn layui-btn-danger layui-btn-xs layui-btn-disabled"  lay-event="check" disabled="disabled">审核</button>
    {{# } }}
    {{# } }}

    {{# if(hasPrivilege("REPLYYY")){ }}
    {{# if(d.remark=="20" && (loginObj.manager.standbyThree == "superman" || loginObj.manager.companyId == 3 )){ }}
    <a class="layui-btn layui-btn-warm layui-btn-xs"  lay-event="reply">回复</a>
    {{# } else{}}
    <button class="layui-btn layui-btn-warm layui-btn-xs layui-btn-disabled"  lay-event="reply" disabled="disabled">回复</button>
    {{# } }}
    {{# } }}

    {{# if(hasPrivilege("COACHYY")){ }}
    {{# if(loginObj.manager.clerkId == d.coachId || loginObj.manager.standbyThree == "superman"){ }}
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    {{# } else{}}
    <button class="layui-btn layui-btn-danger layui-btn-xs layui-btn-disabled" lay-event="del" disabled="disabled">删除</button>
    {{# } }}
    {{# } }}


</script>
</body>
</html>